﻿using Joz.RabbitMQClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Joz.Tasks
{
    public class LogHandle
    {

        /// <summary>
        /// 添加错误日志
        /// </summary>
        /// <param name="parms"></param>
        /// <returns></returns>
        public CommonCmdResult AddErrorLog(byte[] parms)
        {
            try
            {
                CommonCmdResult cmd = new CommonCmdResult(false);
                //处理业务逻辑
                cmd.Flag = true;
                return cmd;
            }
            catch (Exception ex)
            {
                return new CommonCmdResult(false, ex.ToString());
            }
        }
        /// <summary>
        /// 添加浏览记录
        /// </summary>
        /// <param name="parms"></param>
        /// <returns></returns>
        public CommonCmdResult AddBrowseLog(byte[] parms)
        {
            try
            {
                CommonCmdResult cmd = new CommonCmdResult(false);
                //处理业务逻辑
                cmd.Flag = true;
                return cmd;
            }
            catch (Exception ex)
            {
                return new CommonCmdResult(false, ex.ToString());
            }
        }
        /// <summary>
        /// 添加操作日志
        /// </summary>
        /// <param name="parms"></param>
        /// <returns></returns>
        public CommonCmdResult AddOperationLog(byte[] parms)
        {
            try
            {
                CommonCmdResult cmd = new CommonCmdResult(false);
                //处理业务逻辑
                cmd.Flag = true;
                return cmd;
            }
            catch (Exception ex)
            {
                return new CommonCmdResult(false, ex.ToString());
            }
        }
        /// <summary>
        /// 添加登录日志
        /// </summary>
        /// <param name="parms"></param>
        /// <returns></returns>
        public CommonCmdResult AddLoginLog(byte[] parms)
        {
            try
            {
                CommonCmdResult cmd = new CommonCmdResult(false);
                //处理业务逻辑
                cmd.Flag = true;
                return cmd;
            }
            catch (Exception ex)
            {
                return new CommonCmdResult(false, ex.ToString());
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="parms"></param>
        /// <returns></returns>
        public CommonCmdResult WriteLine(byte[] parms)
        {
            var message =
                        MessageSerializerFactory.CreateMessageSerializerInstance()
                            .Deserialize<UpdatePurchaseOrderStatusByBillIdMqContract>(parms);
            LogHelper.WriteErrorLog(message.Guid);
            CommonCmdResult cmd = new CommonCmdResult(false);
            //处理业务逻辑
            cmd.Flag = true;
            return cmd;
        }
    }
}
